package com.magic.ch04_枚举模拟与排序.错误票据;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int n = Integer.parseInt(br.readLine());
        String[] read;
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            read = br.readLine().split(" ");
            for (int j = 0; j < read.length; j++) {
                list.add(Integer.parseInt(read[j]));
            }
        }
        Collections.sort(list);
        int chong = 0, duan = 0;
        for (int i = 1; i < list.size(); i++) {
            if (list.get(i) - list.get(i - 1) == 0) {
                chong = list.get(i);
            }
            if (list.get(i) - list.get(i - 1) == 2) {
                duan = list.get(i) - 1;
            }
        }
        pw.println(duan+" "+chong);
        br.close();
        pw.flush();
        pw.close();
    }
}
